package cn.ahaiahaixx.supemarketonline.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.ahaiahaixx.supemarketonline.model.TbSubTypeModel;
import cn.ahaiahaixx.supemarketonline.model.TbTybeModel;
import cn.ahaiahaixx.supemarketonline.model.TbUserModel;
import cn.ahaiahaixx.supemarketonline.service.SubTypeService;
import cn.ahaiahaixx.supemarketonline.service.TypeService;
import cn.ahaiahaixx.supemarketonline.service.UserService;
import cn.ahaiahaixx.supemarketonline.utils.JsonMessage;

/**
 * 用户控制器
 * 
 * @author Aiden Pearce
 *
 */
@RestController
@RequestMapping("/user")
public class LOGUserController {

  @Autowired
  private UserService userService;
  @Autowired
  private SubTypeService subTypeService;

  @Autowired
  private TypeService typeService;

  @RequestMapping("/login")
  public JsonMessage login(TbUserModel model) throws Exception {
    return userService.login(model);
  }
  // {"tbUser.username":"123","tbUser.password":"123"} //完成

  @RequestMapping("/logout")
  public JsonMessage logout(TbUserModel model) throws Exception {
    return userService.logout(model);
  }
  // 完成

  @RequestMapping("/getUserInfo")
  public JsonMessage getUserInfo(TbUserModel model) throws Exception {
    return userService.getUserInfo(model);
  }

  @RequestMapping("/useradd")
  public JsonMessage useradd(TbUserModel model) throws Exception {
    return userService.useradd(model);
  }

  // {"tbUser.username":"孙笑川","tbUser.password":"6324","tbUser.nickname":"你的哥哥"}
  // 完成
  @RequestMapping("/queryAll")
  public JsonMessage queryAll(TbSubTypeModel model) throws Exception {
    return subTypeService.queryAll(model);
  }
  // 成功

  @RequestMapping("/TypequeryAll")
  public JsonMessage TypequeryAll(TbTybeModel model) throws Exception {
    return typeService.queryAll(model);
  }
  //成功
}
